package com.example.demo;

import com.jfinal.template.Engine;
import io.github.stylesmile.annotation.Controller;
import io.github.stylesmile.annotation.RequestMapping;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

@Controller
public class SwaggerController {
    /**
     * [{"name":"????","url":"/v2/api-docs?group=????","swaggerVersion":"2.0","location":"/v2/api-docs?group=????"}]
     * @return
     * @throws IOException
     */
//    @Produces("application/json; charset=utf-8")
    @RequestMapping("swagger-resources")
    public String resources() throws IOException {
        return "";
    }

    /**
     * swagger 获取分组接口数据
     *
     */
    //{"swagger":"2.0","info":{"description":"`????`,**????** # aaa","version":"v4.0","title":"Knife4j????","termsOfService":"https://stackoverflow.com/","contact":{"name":"????","url":"https://docs.xiaominfo.com","email":"xiaoymin@foxmail.com"},"license":{"name":"Apache 2.0","url":"https://stackoverflow.com/"}},"host":"localhost:8080","basePath":"/","tags":[{"name":"首页模块","x-order":"2147483647"}],"paths":{"/sayHi":{"get":{"tags":["首页模块"],"summary":"向客人问好","operationId":"sayHiUsingGET","produces":["*/*"],"parameters":[{"name":"name","in":"query","description":"姓名","required":true,"type":"string"}],"responses":{"200":{"description":"OK","schema":{"type":"string"}},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden"},"404":{"description":"Not Found"}},"responsesObject":{"200":{"description":"OK","schema":{"type":"string"}},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden"},"404":{"description":"Not Found"}},"deprecated":false,"x-order":"2147483647"}}},"x-openapi":{"x-markdownFiles":null,"x-setting":{"language":"zh-CN","enableSwaggerModels":true,"swaggerModelName":"Swagger Models","enableReloadCacheParameter":false,"enableAfterScript":true,"enableDocumentManage":true,"enableVersion":false,"enableRequestCache":true,"enableFilterMultipartApis":false,"enableFilterMultipartApiMethodType":"POST","enableHost":false,"enableHostText":"","enableDynamicParameter":false,"enableDebug":true,"enableFooter":true,"enableFooterCustom":false,"footerCustomContent":null,"enableSearch":true,"enableOpenApi":true,"enableHomeCustom":false,"homeCustomLocation":null,"enableGroup":true,"enableResponseCode":true}}}
//    @Produces("application/json; charset=utf-8")
    @RequestMapping("swagger/v2")
    public String api(String group) throws IOException {
        Engine engine = Engine.use();
        engine.setDevMode(true);
        engine.setToClassPathSourceFactory();
        engine.getTemplate("index.html");
        return "";
    }

}
